package com.bdqn.systems.auth;

import com.bdqn.response.Result;
import com.bdqn.response.ResultCode;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author : CP
 * @version: 1.0
 * @program : xinguan-parent
 * @description : 登出成功处理
 * @date : 2020-12-26 11:30
 **/
@Component
public class MyLoginoutSuccessHandler extends JSONAuthentication implements LogoutSuccessHandler {


    /**
     * 登出成功
     * @param httpServletRequest
     * @param httpServletResponse
     * @param authentication
     * @throws IOException
     * @throws ServletException
     */
    @Override
    public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
        Result error = Result.error(ResultCode.USER_ACCOUNT_USE_BY_OTHERS);
        this.WriteJSON(httpServletRequest,httpServletResponse,error);
    }
}
